/**
 * Created by Lwang on 2017-03-30.
 */
import Util from "utils";

var listDetailCtrl = ['$scope', '$stateParams', '$state', '$location', '$http', '$timeout', '$rootScope', 'Http', function ($scope, $stateParams, $state, $location, $http, $timeout, $rootScope, Http) {
    var id = $state.params.productId;
    $scope.detail = "";
    Http.request({
        url: Util.ajax.productInfo(id),
        method: "get",
        success: function (res) {
            Http.handler(Util.merge(res, {
                success: function (result) {
                    $scope.detail = result;
                }
            }))

        }
    });


    //到期时间处理
    $scope.dateCancle = function (time) {
        var date = new Date(time);
        var year = date.getFullYear();
        var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : (date.getMonth() + 1);
        var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
        return year + "-" + month + "-" + day;
    };
    //投资周期处理
    $scope.monthCancle = function (day) {
        return Math.round(day / 30);
    }
}];
export {listDetailCtrl};